Patterns for computational effects arising from a monad or a comonad
نویسندگان
چکیده
This paper presents equational-based logics for proving first order properties of programming languages involving effects. We propose two dual inference system patterns that can be instanciated with monads or comonads in order to be used for proving properties of different effects. The first pattern provides inference rules which can be interpreted in the Kleisli category of a monad and the coKleisli category of the associated comonad. In a dual way, the second pattern provides inference rules which can be interpreted in the coKleisli category of a comonad and the Kleisli category of the associated monad. The logics combine a 3-tier effect system for terms consisting of pure terms and two other kinds of effects called ’constructors/observers’ and ’modifiers’, and a 2-tier system for ’up-to-effects’ and ’strong’ equations. Each pattern provides generic rules for dealing with any monad (respectively comonad), and it can be extended with specific rules for each effect. The paper presents two use cases: a language with exceptions (using the standard monadic semantics), and a language with state (using the less standard comonadic semantics). Finally, we prove that the obtained inference system for states is Hilbert-Post complete.
منابع مشابه
Should I use a Monad or a Comonad ?
The category theoretic structures of monads and comonads can be used as an abstraction mechanism for simplifying both language semantics and programs. Monads have been used to structure impure computations, whilst comonads have been used to structure context-dependent computations. Interestingly, the class of computations structured by monads and the class of computations structured by comonads...
متن کاملA Linear-non-Linear Model for a Computational Call-by-Value Lambda Calculus (Extended Abstract)
We give a categorical semantics for a call-by-value linear lambda calculus. Such a lambda calculus was used by Selinger and Valiron as the backbone of a functional programming language for quantum computation. One feature of this lambda calculus is its linear type system, which includes a duplicability operator “!” as in linear logic. Another main feature is its call-by-value reduction strategy...
متن کاملAlgebraic Weak Factorisation Systems I: Accessible Awfs
Algebraic weak factorisation systems (awfs) refine weak factorisation systems by requiring that the assignations sending a map to its first and second factors should underlie an interacting comonad–monad pair on the arrow category. We provide a comprehensive treatment of the basic theory of awfs—drawing on work of previous authors—and complete the theory with two main new results. The first pro...
متن کاملCoalgebraic semantics for timed processes
We give a coalgebraic formulation of timed processes and their operational semantics. We model time by a monoid called a “time domain”, and we model processes by “timed transition systems”, which amount to partial monoid actions of the time domain or, equivalently, coalgebras for an “evolution comonad” generated by the time domain. All our examples of time domains satisfy a partial closure prop...
متن کاملThe 2-category of Weak Entwining Structures
A weak entwining structure in a 2-category K consists of a monad t and a comonad c, together with a 2-cell relating both structures in a way that generalizes a mixed distributive law. A weak entwining structure can be characterized as a compatible pair of a monad and a comonad, in 2-categories generalizing the 2-category of comonads and the 2-category of monads in K , respectively. This observa...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- CoRR
دوره abs/1310.0605 شماره
صفحات -
تاریخ انتشار 2013